<?php
$this->lang->load('admin_ad', $this->session->admin_language);
$this->load->view('admin/layout/head', array('title'=> '系统设置'), FALSE);
?>

<div id="container">

	<form class="form-inline" id="search-form" method="GET" action="/admin/ad">
	  <a href="/admin/sys/add" class="btn btn-default add-btn"><span class="glyphicon glyphicon-plus"></span> <?php echo $this->lang->line('add') ?></a>
	  <a href="/admin/sys/logo" class="btn btn-default add-btn"><span class="glyphicon glyphicon-plus"></span> <?php echo $this->lang->line('logo_setting') ?></a>
	  <a href="/admin/sys/video" class="btn btn-default add-btn"><span class="glyphicon glyphicon-plus"></span> <?php echo $this->lang->line('video_setting') ?></a>
	  <a href="/admin/sys/email" class="btn btn-default add-btn"><span class="glyphicon glyphicon-plus"></span> email</a>
	</form>


	<div class="table-container mt-10">
		<table class="table table-bordered table-striped table-hover scroll-table">
			<thead >
				<tr>
					<th width="100" class="text-center">标签</th>
					<th width="100" class="text-center">名称</th>
					<th width="60" class="text-center">值</th>
					<th width="80" class="text-center"><?php echo $this->lang->line('actions') ?></th>
				</tr>
			</thead>
			<tbody class="text-center">
				<?php foreach($configs as $config): ?>
				<tr id='tr-<?php echo $config['id']?>'>
					<td class="text-left">
						<?= $config['label'] ?>
					</td>
					<td>
						<?= $config['name'] ?>
					</td>
					<td>
						<?= $config['value'] ?>
					</td>
					<td>
						<a href="/admin/sys/edit/<?= $config['id'] ?>" class="modify-btn"><?php echo $this->lang->line('edit') ?></a> |
						<a href="javascript:;" class="del-btn" id="<?= $config['id'] ?>"><?php echo $this->lang->line('delete') ?></a>
					</td>
				</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
	</div>
</div>


<?php
$this->load->view('admin/layout/footer');
?>

<script>
$(function () {
	$('.del-btn').on('click',function(){
		var id = $(this).attr('id');
		confirm('<?php echo $this->lang->line('delete_confirm') ?>',function(e){
			if(e.index == 1){
				Toast.loading();
				$.post('/admin/sys/delete/'+id, function(data, textStatus, xhr) {
					Toast.destory();
					Toast.success('<?php echo $this->lang->line('delete_success') ?>',function(){
						window.location.reload();
					});
				});
			}
		})
	});
})
</script>
